package com.speedata;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.google.android.flexbox.FlexDirection;
import com.google.android.flexbox.FlexboxLayout;
import com.speedata.uhftest.R;

/**
 * @author xuyan
 */
public class FlexboxTextActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flexbox_text);
        initView();
        senBroadcasts(true);
    }

    private void initView() {
        FlexboxLayout flexboxLayout = findViewById(R.id.flexbox_layout);
        flexboxLayout.setFlexDirection(FlexDirection.ROW);
        View view = flexboxLayout.getChildAt(0);
        FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams();
        lp.setOrder(-1);
        lp.setFlexGrow(2);
        view.setLayoutParams(lp);
    }

    /**
     * 将扫描结果放在焦点上
     *
     * @param string 扫描内容
     */
    public void senBroadcasts(boolean string) {
        Intent intents = new Intent();
        intents.setAction("com.speedata.action.set_xwindows");
        intents.putExtra("enable", string);
        this.sendBroadcast(intents);
    }


}
